package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.impl.RCEnterpriseImpl;
import com.shrct.businessprocess.product.RCProductPurchaseInfo;
import com.shrct.businessprocess.product.RCProductPurchaseInfoDeliverTarget;
import com.shrct.businessprocess.product.impl.RCProductPurchaseInfoImpl;
import com.shrct.businessprocess.product.proxy.RCProductPurchaseInfoDeliverTargetProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPRODUCTPURCHASEINFODELIVERTARGET_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcproductpurchaseinfodelivertarget")
public class RCProductPurchaseInfoDeliverTargetImpl extends BaseModelObject implements RCProductPurchaseInfoDeliverTarget {
  public RCProductPurchaseInfoDeliverTargetImpl() {
    super();
  }
  
  public RCProductPurchaseInfoDeliverTargetImpl(final RCProductPurchaseInfo purchaseInfo) {
    super();
    this.purchaseInfo = purchaseInfo;
  }
  
  @JoinColumn(name = "purchaseInfo_id")
  @ManyToOne(targetEntity = RCProductPurchaseInfoImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductPurchaseInfo purchaseInfo;
  
  public RCProductPurchaseInfo getPurchaseInfo() {
    return this.purchaseInfo;
  }
  
  public RCProductPurchaseInfoDeliverTarget setPurchaseInfo(final RCProductPurchaseInfo purchaseInfo) {
    this.purchaseInfo = purchaseInfo;
    return this;			
    
  }
  
  private Integer quantity;
  
  public Integer getQuantity() {
    return this.quantity;
  }
  
  public RCProductPurchaseInfoDeliverTarget setQuantity(final Integer quantity) {
    this.quantity = quantity;
    return this;			
    
  }
  
  @JoinColumn(name = "deliverTarget_id")
  @ManyToOne(targetEntity = RCEnterpriseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEnterprise deliverTarget;
  
  public RCEnterprise getDeliverTarget() {
    return this.deliverTarget;
  }
  
  public RCProductPurchaseInfoDeliverTarget setDeliverTarget(final RCEnterprise deliverTarget) {
    this.deliverTarget = deliverTarget;
    return this;			
    
  }
  
  public static RCProductPurchaseInfoDeliverTarget create(final RCProductPurchaseInfo purchaseInfo, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCProductPurchaseInfoDeliverTarget rCProductPurchaseInfoDeliverTarget = new com.shrct.businessprocess.product.impl.RCProductPurchaseInfoDeliverTargetImpl(
    	purchaseInfo
    );
    objectFactory.create(rCProductPurchaseInfoDeliverTarget);
    return rCProductPurchaseInfoDeliverTarget;			
    
  }
  
  public static RCProductPurchaseInfoDeliverTarget createRCProductPurchaseInfoDeliverTargetImpl(final RCProductPurchaseInfo purchaseInfo, final IObjectFactory objectFactory, final Procedure1<RCProductPurchaseInfoDeliverTarget> init) {
    com.shrct.businessprocess.product.RCProductPurchaseInfoDeliverTarget rCProductPurchaseInfoDeliverTarget = new com.shrct.businessprocess.product.impl.RCProductPurchaseInfoDeliverTargetImpl(
    	purchaseInfo
    );
    objectFactory.create(rCProductPurchaseInfoDeliverTarget);
    init.apply(rCProductPurchaseInfoDeliverTarget);
    
    return rCProductPurchaseInfoDeliverTarget;			
    
  }
  
  public RCProductPurchaseInfoDeliverTargetProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCProductPurchaseInfoDeliverTargetProxy proxy = new com.shrct.businessprocess.product.proxy.RCProductPurchaseInfoDeliverTargetProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
